home *** CD-ROM | disk | FTP | other *** search
- /* ******************************************************************** */
- /* C code generated by: */
- /* Visual Arts Version 2.1 */
- /* Copyright 1994-95 Danny Y. Wong All rights reserved */
- /* Calgary, Alberta (CANADA) */
- /* Partial of the code is copyright by Jaba Development */
- /* ******************************************************************** */
-
- #include <VisualArts.h>
- #include <clib/VisualArts_protos.h>
-
- #define ID_write 0
- #define ID_quit 1
- #define ID_entry 2
- #define ID_device 3
- #define ID_Display 4
-
- #define ClipBoardNumGads 5
-
- #include "ClipBoard_func.c"
-
- int writeObj(struct VAobject VAObject);
- int quitObj(struct VAobject VAObject);
- int entryObj(struct VAobject VAObject);
- int deviceObj(struct VAobject VAObject);
-
- int GetPubScreen(void);
- void ClosePubScreen(void);
- int OpenClipBoardWindow(char windtitle[]);
- void CloseClipBoardWindow(void);
- int ClipBoardHandler(void);
- int ClipBoardMainHandler(void);
- void DrawClipBoardObjs(void);
- int main(int argc, char *argv[]);
-
- UBYTE *PubScrName = "Workbench";
- struct DrawInfo *ScrDrawInfo = NULL;
- APTR VisualInfo = NULL;
- struct Screen *Scr = NULL;
- struct Window *ClipBoardWnd = NULL;
- struct Gadget *ClipBoardGList = NULL;
- struct Gadget *ClipBoardGadgets[ClipBoardNumGads];
- struct IntuiMessage ClipBoardMsg;
- UWORD ClipBoardLeft = 115;
- UWORD ClipBoardTop = 47;
- UWORD ClipBoardWidth = 368;
- UWORD ClipBoardHeight = 62;
-
- /* stringinfo for WB 1.x style string/integer gadgets */
-
- struct StringExtend ClipBoardStrExt; /* Extend String Gadget */
- struct TextAttr topaz8 = { (STRPTR)"topaz.font", 8, 0x00, 0x01 };
- struct TextAttr topaz800 = { (STRPTR)"topaz.font", 8, 0x00, 0x00 };
-
- UBYTE *DevicesLabels[] = {
- (UBYTE *)"0",
- (UBYTE *)"1",
- (UBYTE *)"2",
- (UBYTE *)"3",
- (UBYTE *)"4",
- (UBYTE *)"5",
- (UBYTE *)"6",
- (UBYTE *)"7",
- (UBYTE *)"8",
- (UBYTE *)"9",
- NULL
- };
-
- WORD ClipBoardGadTypes[] = {
- BUTTON_KIND,
- BUTTON_KIND,
- STRING_KIND,
- CYCLE_KIND,
- TEXT_KIND,
- };
-
- struct NewGadget ClipBoardNGads[] = {
- 210, 34, 56, 13, (UBYTE *)"Write",&topaz800, ID_write, PLACETEXT_IN, NULL, (APTR)writeObj,
- 300, 34, 56, 13, (UBYTE *)"Quit",&topaz800, ID_quit, PLACETEXT_IN, NULL, (APTR)quitObj,
- 81, 19, 275, 13, (UBYTE *)"Entry", &topaz800, ID_entry, PLACETEXT_LEFT, NULL, (APTR)entryObj,
- 81, 34, 94, 13, (UBYTE *)"Device", &topaz800, ID_device, PLACETEXT_LEFT, NULL, (APTR)deviceObj,
- 81, 2, 275, 15, (UBYTE *)"ClipBoard", &topaz800, ID_Display, PLACETEXT_LEFT, NULL, NULL,
- };
-
- ULONG ClipBoardNTags[] = {
- TAG_DONE,
- TAG_DONE,
- (GTST_String), (ULONG)"Visual Arts", GTST_MaxChars, 40, (STRINGA_Justification), GACT_STRINGLEFT, TAG_DONE,
- (GTCY_Labels), (ULONG)&DevicesLabels[0], (GTCY_Active), 0, TAG_DONE,
- (GTTX_Text),(ULONG)"", (GTTX_Border), TRUE, TAG_DONE,
- };
-
-
- int GetPubScreen(void)
- {
- if (!(Scr = LockPubScreen(PubScrName)))
- return(1L);
-
- if (!(VisualInfo = GetVisualInfo(Scr, TAG_DONE)))
- return(2L);
-
- if (!(ScrDrawInfo = GetScreenDrawInfo(Scr)))
- return(3L);
- return(0L);
- }
-
- void ClosePubScreen(void)
- {
- if (VisualInfo)
- FreeVisualInfo(VisualInfo);
- if (Scr)
- UnlockPubScreen(NULL, Scr);
- if (ScrDrawInfo)
- FreeScreenDrawInfo(Scr, ScrDrawInfo);
- }
-
- int OpenClipBoardWindow(char windtitle[80])
- {
- struct NewGadget NewGad;
- struct Gadget *Gad;
- register UWORD i, j;
- UWORD offsetx = Scr->WBorLeft;
- UWORD offsety = Scr->WBorTop + Scr->Font->ta_YSize + 1;
-
-
- ClipBoardStrExt.Font = NULL;
- ClipBoardStrExt.Pens[0] = 1;
- ClipBoardStrExt.Pens[1] = 0;
- ClipBoardStrExt.ActivePens[0] = 2;
- ClipBoardStrExt.ActivePens[1] = 0;
- ClipBoardStrExt.InitialModes = 0;
- ClipBoardStrExt.EditHook = NULL;
- ClipBoardStrExt.WorkBuffer = NULL;
-
- if (!(Gad = CreateContext(&ClipBoardGList)))
- return(1L);
-
- for (i=0, j=0; i < ClipBoardNumGads; i++)
- {
- CopyMem((char *)&ClipBoardNGads[i], (char *)&NewGad, (long)sizeof(struct NewGadget));
-
- NewGad.ng_VisualInfo = VisualInfo;
- NewGad.ng_LeftEdge += offsetx;
- NewGad.ng_TopEdge += offsety;
-
- ClipBoardGadgets[i] = Gad = CreateGadgetA((ULONG)ClipBoardGadTypes[i], Gad, &NewGad,
- (struct TagItem *)&ClipBoardNTags[j]);
- if (ClipBoardGadTypes[i] == STRING_KIND || ClipBoardGadTypes[i] == INTEGER_KIND)
- {
- ClipBoardGadgets[i]->Flags |= GFLG_STRINGEXTEND;
- ((struct StringInfo *)ClipBoardGadgets[i]->SpecialInfo)->Extension = &ClipBoardStrExt;
- }
- while (ClipBoardNTags[j])
- j +=2;
- j++;
- if (!Gad)
- return(2L);
- }
- if (!(ClipBoardWnd = OpenWindowTags(NULL,
- WA_Left, ClipBoardLeft,
- WA_Top, ClipBoardTop,
- WA_Width, ClipBoardWidth,
- WA_Height, ClipBoardHeight + kWindowOffSetY,
- WA_NewLookMenus, TRUE,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_NEWSIZE | IDCMP_GADGETUP ,
- WA_Flags, WFLG_CLOSEGADGET | WFLG_DEPTHGADGET | WFLG_SMART_REFRESH |
- WFLG_RMBTRAP | WFLG_ACTIVATE |
- WFLG_DRAGBAR ,
- WA_Gadgets, ClipBoardGList,
- WA_Title, windtitle,
- WA_ScreenTitle, "Visual Arts V2.2 Copyright 1994-95 Danny Y. Wong All Rights Reserved.",
- WA_PubScreen, Scr,
- WA_MinWidth, 160,
- WA_MinHeight, 50,
- WA_MaxWidth, 640,
- WA_MaxHeight, 200,
- TAG_DONE)))
- return(3L);
-
- CreateClipBoardLists();
- GT_RefreshWindow(ClipBoardWnd, NULL);
- RefreshGadgets(ClipBoardGadgets[0], ClipBoardWnd, NULL);
- return(0L);
- }
-
- void CloseClipBoardWindow(void)
- {
- if (ClipBoardWnd)
- CloseWindow(ClipBoardWnd);
- if (ClipBoardGList)
- FreeGadgets(ClipBoardGList);
- }
-
- int ClipBoardHandler(void)
- {
- struct IntuiMessage *msg;
- struct VAobject VAObject;
- int running = 1;
- int (*func)(struct VAobject VAObject);
- ULONG class;
- UWORD code;
-
- while (msg=GT_GetIMsg(ClipBoardWnd->UserPort))
- {
- CopyMem((char *)msg, (char *)&ClipBoardMsg, (long)sizeof(struct IntuiMessage));
- class = msg->Class;
- code = msg->Code;
-
- VAObject.va_Window = (struct Window *)ClipBoardWnd;
- VAObject.va_Gadget = (struct Gadget *)msg->IAddress;
- VAObject.va_IntuiMsg = (struct IntuiMessage *)msg;
- VAObject.va_Flags = 0;
- VAObject.va_UserData = 0;
-
- GT_ReplyIMsg(msg);
- switch(class)
- {
-
- case IDCMP_NEWSIZE:
- break;
-
- case IDCMP_CLOSEWINDOW:
- return(0);
- break;
-
- case IDCMP_GADGETUP:
- func = (void *)((struct Gadget *)ClipBoardMsg.IAddress)->UserData;
- if (func != NULL)
- running = func(VAObject);
- break;
-
- }
- }
- return(running);
- }
-
- int ClipBoardMainHandler(void)
- {
- int running = 1;
- ULONG windsig, signals;
-
- windsig = 1L << ClipBoardWnd->UserPort->mp_SigBit;
-
- while (running == 1)
- {
- signals = Wait( windsig );
- if (signals & windsig)
- {
- running = ClipBoardHandler();
- }
- }
- return(running);
- }
-
- int main(int argc, char *argv[])
- {
- int rc;
-
- if (!(GetPubScreen()))
- {
- for (rc=0; rc < 1; rc++)
- ClipBoardLists[rc]=GetNewList();
- if (!(OpenClipBoardWindow("ClipBoard Demo")))
- {
- rc = ClipBoardMainHandler();
- CloseClipBoardWindow();
- }
- for (rc=0; rc < 1; rc++)
- FreeList(ClipBoardLists[rc]);
- ClosePubScreen();
- }
- return(0L);
- }
-